import sys 
sys.path.append("../")
from UI.function_page_ui import Ui_MainWindow as function_page
from PyQt5.QtWidgets import QMainWindow
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QMessageBox
from database.database import DataBase
from crud.select import Demo
from Identify.identify_test import Window as Test
from Identify.identify_camera import Window as Camera

class Main_Ui(QMainWindow, function_page):
    def __init__(self, model_path="../plate_detect/ultralytics/weights/best.pt", db_path="../database/plave_data.db",uid = 1):
        super(Main_Ui, self).__init__()
        self.setupUi(self)
        self.pushButton.clicked.connect(self.viewBill)
        self.pushButton_2.clicked.connect(self.viewAdmin)
        self.pushButton_3.clicked.connect(self._Test)
        self.pushButton_4.clicked.connect(self._Camera)
        self.pushButton_5.clicked.connect(self.close)
        self.db_path = db_path
        self.Test = Test(path=model_path, db_path=db_path, uid=uid)
        self.Camera = Camera(path=model_path, db_path=db_path)
        self.record_deom = None
        self.user_demo = None

    # 查看账单信息
    def viewBill(self):
        self.record_deom = Demo(table_name="Record",title_list=["交易ID","管理员ID","金额","具体菜品及其数量","时间"], db_path=self.db_path)
        self.record_deom.show()

    # 查看管理员信息
    def viewAdmin(self):
        self.user_demo = Demo(table_name="User",title_list=["用户ID","用户名","密码"], db_path=self.db_path)
        self.user_demo.resize(255, 300)
        self.user_demo.show()

    # 测试
    def _Test(self):
        self.Test.show()

    # 摄像头
    def _Camera(self):
        self.Camera.show()
         

if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    ui = Main_Ui()
    ui.show()
    sys.exit(app.exec_())
